package com.siwei.mes.entity.mixproportion;

import cn.dev33.satoken.stp.StpUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.siwei.mes.common.validator.AddGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
import java.util.List;


/**
 * 配合比表(MixProportion)实体类
 *
 * @author dmwang
 * @since 2024-07-29 21:01:49
 */
@Data
@Accessors(chain = true)
@Table(name = "pk_mix_proportion")
@ApiModel(value = "MixProportion", description = "配合比表")
public class MixProportion implements Serializable {
    private static final long serialVersionUID = -41643776887601334L;
    /**
     * 主键
     */
    @Id
    @ApiModelProperty(value = "配合比表主键ID", name = "id")
    private Long id;
    /**
     * 配合比编码
     */
    @Column(name = "proportion_phb")
    @ApiModelProperty(value = "配合比编码", name = "proportionPhb")
    @NotBlank(groups = {AddGroup.class}, message = "配合比编码为空！")
    private String proportionPhb;
    /**
     * 设计依据
     */
    @Column(name = "proportion_sjyj")
    @ApiModelProperty(value = "设计依据", name = "proportionSjyj")
    private String proportionSjyj;
    /**
     * 强度等级
     */
    @Column(name = "proportion_qddj")
    @ApiModelProperty(value = "强度等级", name = "proportionQddj")
    @NotBlank(groups = {AddGroup.class}, message = "强度等级/砼品种为空")
    private String proportionQddj;

    /**
     * 搅拌时间
     */
    @Column(name = "proportion_jbsj")
    @ApiModelProperty(value = "搅拌时间", name = "proportionJbsj")
    private String proportionJbsj;

    /**
     * 龄期
     */
    @Column(name = "proportion_lq")
    @ApiModelProperty(value = "龄期", name = "proportionLq")
    @NotBlank(groups = {AddGroup.class}, message = "龄期为空")
    private String proportionLq;
    /**
     * 抗折强度
     */
    @Column(name = "proportion_kzqd")
    @ApiModelProperty(value = "抗折强度", name = "proportionKzqd")
    private String proportionKzqd;
    /**
     * 抗渗等级
     */
    @Column(name = "proportion_ksdj")
    @ApiModelProperty(value = "抗渗等级", name = "proportionKsdj")
    private String proportionKsdj;
    /**
     * 强氯离子
     */
    @Column(name = "proportion_qllz")
    @ApiModelProperty(value = "强氯离子", name = "proportionQllz")
    private String proportionQllz;
    /**
     * 设计塌落度
     */
    @Column(name = "proportion_tld")
    @ApiModelProperty(value = "设计塌落度", name = "proportionTld")
    private JSONObject proportionTld;
    /**
     * 粘聚性
     */
    @Column(name = "proportion_zjx")
    @ApiModelProperty(value = "粘聚性", name = "proportionZjx")
    private String proportionZjx;
    /**
     * 保水性
     */
    @Column(name = "proportion_bsx")
    @ApiModelProperty(value = "保水性", name = "proportionBsx")
    private String proportionBsx;
    /**
     * 生产水胶比
     */
    @Column(name = "production_sjb")
    @ApiModelProperty(value = "生产水胶比", name = "productionSjb")
    private String productionSjb;
    /**
     * 生产容重
     */
    @Column(name = "production_rz")
    @ApiModelProperty(value = "生产容重", name = "productionRz")
    private String productionRz;
    /**
     * 生产砂率
     */
    @Column(name = "production_sl")
    @ApiModelProperty(value = "生产砂率", name = "productionSl")
    private String productionSl;

    /**
     * 生产外加剂掺量
     */
    @Column(name = "production_cl")
    @ApiModelProperty(value = "生产外加剂掺量", name = "productionCl")
    private String productionCl;

    /**
     * 打印水胶比
     */
    @Column(name = "print_sjb")
    @ApiModelProperty(value = "打印水胶比", name = "printSjb")
    private String printSjb;
    /**
     * 打印容重
     */
    @Column(name = "print_rz")
    @ApiModelProperty(value = "打印容重", name = "printRz")
    private String printRz;
    /**
     * 打印砂率
     */
    @Column(name = "print_sl")
    @ApiModelProperty(value = "打印砂率", name = "printSl")
    private String printSl;

    /**
     * 打印外加剂掺量
     */
    @Column(name = "print_cl")
    @ApiModelProperty(value = "打印外加剂掺量", name = "printCl")
    private String printCl;

    /**
     * 备注
     */
    @Column(name = "proportion_remarks")
    @ApiModelProperty(value = "备注", name = "proportionRemarks")
    private String proportionRemarks;
    /**
     * 原材料json
     */
    @Column(name = "proportion_material")
    @ApiModelProperty(value = "原材料json", name = "proportionMaterial")
    private JSONObject proportionMaterial;

    @Column(name = "backward_compatible")
    @ApiModelProperty(value = "是否向下兼容抗渗等级(1是，0不是)", name = "backwardCompatible")
    private Integer backwardCompatible;

    @Column(name = "new_ratio")
    @ApiModelProperty(value = "新配比json", name = "newRatio")
    private JSONArray newRatio;

    /**
     * 新配比结果集
     */
    @Column(name = "new_ratio_string")
    @ApiModelProperty(value = "新配比结果集", name = "newRatioString")
    private String newRatioString;


    @Column(name = "report_date")
    @ApiModelProperty(value = "报告日期")
    private Date reportDate;
    /**
     * 协会上传状态
     */
    @Column(name = "xh_status")
    @ApiModelProperty(value = "协会上传状态", name = "xhStatus")
    private String xhStatus;

    @Column(name = "erp_phb_id")
    @ApiModelProperty(value = "erp配合比唯一id", name = "erpPhbId")
    private String erpPhbId;

    /**
     * erp上传状态
     */
    @Column(name = "erp_status")
    @ApiModelProperty(value = "erp上传状态", name = "erpStatus")
    private String erpStatus;

    @Column(name = "xh_reason")
    @ApiModelProperty(value = "协会上传失败原因", name = "xhReason")
    private String xhReason;

    @Column(name = "erp_reason")
    @ApiModelProperty(value = "erp上传失败原因", name = "erpReason")
    private String erpReason;

    /**
     * 创建人  派单人
     */
    @Column(name = "creater")
    @ApiModelProperty(value = "创建人  派单人", name = "creater")
    private Long creater;
    /**
     * 创建时间
     */
    @Column(name = "create_time")
    @ApiModelProperty(value = "创建时间", name = "createTime")
    private Date createTime;
    /**
     * 修改人
     */
    @Column(name = "updater")
    @ApiModelProperty(value = "修改人", name = "updater")
    private Long updater;
    /**
     * 更新时间
     */
    @Column(name = "update_time")
    @ApiModelProperty(value = "更新时间", name = "updateTime")
    private Date updateTime;
    /**
     * 是否删除  1-删除
     */
    @Column(name = "is_del")
    @ApiModelProperty(value = "是否删除  1-删除", name = "isDel")
    private Integer isDel;

    //id集合
    @Transient
    @ApiModelProperty(value = "多个配合比id")
    private List<Long> ids;

    @Transient
    @ApiModelProperty(value = "强度等级集合")
    private List<String> proportionQddjList;

    @Transient
    @ApiModelProperty(value = "抗渗等级集合")
    private List<String> proportionKsdjList;

    public MixProportion init(boolean isCreate) {
        this.setUpdater(StpUtil.isLogin() ? StpUtil.getLoginIdAsLong() : null)
                .setUpdateTime(new Date());
        if (isCreate) {
            this.setCreater(StpUtil.isLogin() ? StpUtil.getLoginIdAsLong() : null)
                    .setCreateTime(new Date())
                    .setIsDel(0);
        }
        return this;
    }

}
